<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Hammerspoon docs: UniversalArchive</title>
    <style type="text/css">
      a { text-decoration: none; }
      a:hover { text-decoration: underline; }
      th { background-color: #DDDDDD; vertical-align: top; padding: 3px; }
      td { width: 100%; background-color: #EEEEEE; vertical-align: top; padding: 3px; }
      table { width: 100% ; border: 1px solid #0; text-align: left; }
      section > table table td { width: 0; }
    </style>
    <link rel="stylesheet" href="docs.css" type="text/css" media="screen" />
  </head>
  <body>
    <header>
      <h1><a href="./index.html">docs</a> &raquo; UniversalArchive</h1>
      <p>Handle &quot;archive current item&quot; for multiple applications using the same hotkey</p>
<p>Download: <a href="https://github.com/Hammerspoon/Spoons/raw/master/Spoons/UniversalArchive.spoon.zip">https://github.com/Hammerspoon/Spoons/raw/master/Spoons/UniversalArchive.spoon.zip</a></p>
<p>Using this Spoon enables you to use a single hotkey to archive an
item in multiple applications.  Out of the box the following
applications are supported: Evernote, Mail, Spark and Outlook. You
can easily register handlers for new applications (or override the
built-in ones) using the <code>registerApplication()</code> method. If you
write a new handler and feel others could benefit from it, please
submit a pull request!</p>
<p>Handlers can also provide support for archiving to multiple
locations, and you can bind different hotkeys for each
destination. At the moment only Evernote supports this. See the
documentation for <code>bindHotkeys()</code> for the details on how to
specify multiple-destination filing hotkeys.</p>

      </header>
      <h3>API Overview</h3>
      <ul>
        <li>Variables - Configurable values</li>
          <ul>
            <li><a href="#archive_notifications">archive_notifications</a></li>
            <li><a href="#evernote_archive_notebook">evernote_archive_notebook</a></li>
            <li><a href="#evernote_delay_before_typing">evernote_delay_before_typing</a></li>
            <li><a href="#logger">logger</a></li>
            <li><a href="#outlook_archive_folder">outlook_archive_folder</a></li>
          </ul>
        <li>Methods - API calls which can only be made on an object returned by a constructor</li>
          <ul>
            <li><a href="#bindHotkeys">bindHotkeys</a></li>
            <li><a href="#evernoteArchive">evernoteArchive</a></li>
            <li><a href="#mailArchive">mailArchive</a></li>
            <li><a href="#outlookArchive">outlookArchive</a></li>
            <li><a href="#registerApplication">registerApplication</a></li>
            <li><a href="#sparkArchive">sparkArchive</a></li>
            <li><a href="#universalArchive">universalArchive</a></li>
          </ul>
      </ul>
      <h3>API Documentation</h3>
        <h4 class="documentation-section">Variables</h4>
          <section id="archive_notifications">
            <a name="//apple_ref/cpp/Variable/archive_notifications" class="dashAnchor"></a>
            <h5><a href="#archive_notifications">archive_notifications</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.archive_notifications</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Boolean indicating whether a notification should be produced when an item is archived. Defaults to &quot;true&quot;.</p>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L46">Source/UniversalArchive.spoon/init.lua line 46</a></td>
              </tr>
            </table>
          </section>
          <section id="evernote_archive_notebook">
            <a name="//apple_ref/cpp/Variable/evernote_archive_notebook" class="dashAnchor"></a>
            <h5><a href="#evernote_archive_notebook">evernote_archive_notebook</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.evernote_archive_notebook</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Name of the Notebook to use for archiving in Evernote. Defaults to &quot;Archive&quot;</p>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L36">Source/UniversalArchive.spoon/init.lua line 36</a></td>
              </tr>
            </table>
          </section>
          <section id="evernote_delay_before_typing">
            <a name="//apple_ref/cpp/Variable/evernote_delay_before_typing" class="dashAnchor"></a>
            <h5><a href="#evernote_delay_before_typing">evernote_delay_before_typing</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.evernote_delay_before_typing</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>A short pause to make typing into Evernote more reliable</p>
</td>
              </tr>
              <tr>
                  <th>Notes</th>
                  <td><ul>
<li>In Evernote, archive is done by selectin &quot;Move note&quot; and then simulating typing of the notebook name. A short pause in between makes it more reliable for Evernote to recognize the notebook name correctly.</li>
<li>This variable controls how much to wait, in seconds.</li>
<li>Do not change this unless you know what you are doing</li>
</ul>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L51">Source/UniversalArchive.spoon/init.lua line 51</a></td>
              </tr>
            </table>
          </section>
          <section id="logger">
            <a name="//apple_ref/cpp/Variable/logger" class="dashAnchor"></a>
            <h5><a href="#logger">logger</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.logger</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Logger object used within the Spoon. Can be accessed to set the default log level for the messages coming from the Spoon.</p>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L31">Source/UniversalArchive.spoon/init.lua line 31</a></td>
              </tr>
            </table>
          </section>
          <section id="outlook_archive_folder">
            <a name="//apple_ref/cpp/Variable/outlook_archive_folder" class="dashAnchor"></a>
            <h5><a href="#outlook_archive_folder">outlook_archive_folder</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive.outlook_archive_folder</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Variable</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Name of the mailbox to use for archiving in Outlook. You must move a message manually to that mailbox at least once so that it appears in the &quot;Message&quot; -&gt; &quot;Move...&quot; submenu. Defaults to &quot;Archive&quot;</p>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L41">Source/UniversalArchive.spoon/init.lua line 41</a></td>
              </tr>
            </table>
          </section>
        <h4 class="documentation-section">Methods</h4>
          <section id="bindHotkeys">
            <a name="//apple_ref/cpp/Method/bindHotkeys" class="dashAnchor"></a>
            <h5><a href="#bindHotkeys">bindHotkeys</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:bindHotkeys(mapping)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Binds hotkeys for UniversalArchive</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>mapping - A table containing hotkey modifier/key details for the following items:<ul>
<li><code>archive</code> - hotkey for trigger the <code>universalArchive()</code> method, to archive the current item on the current application.</li>
<li><code>&lt;app&gt;_&lt;dest&gt;</code> - if an application handler supports multiple destinations, you can specify hotkeys for specific destinations using this format. For example, to assign a hotkey that files the current note in Evernote to the &quot;MyProject&quot; notebook using Ctrl-Alt-Cmd-M, you would specify <code>Evernote_MyProject = { { &quot;ctrl&quot;, &quot;alt&quot;, &quot;cmd&quot; }, &quot;m&quot; }</code> as one of the elements of <code>mapping</code>. Keep in mind that the application name must appear exactly as the system sees it (including upper/lowercase), and that if either the application or the destination name contain spaces or other non-alphanumeric characters, you need to use the Lua table notation. For example: <code>[&quot;Evernote_Some Long Notebook Name&quot;] = { keybinding }</code>. At the moment only the Evernote handler supports multiple destinations.</li>
</ul>
</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L183">Source/UniversalArchive.spoon/init.lua line 183</a></td>
              </tr>
            </table>
          </section>
          <section id="evernoteArchive">
            <a name="//apple_ref/cpp/Method/evernoteArchive" class="dashAnchor"></a>
            <h5><a href="#evernoteArchive">evernoteArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:evernoteArchive(where)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current note in Evernote.</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>where - destination notebook. Defaults to the value of <code>UniversalArchive.evernote_archive_notebook</code>.</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L61">Source/UniversalArchive.spoon/init.lua line 61</a></td>
              </tr>
            </table>
          </section>
          <section id="mailArchive">
            <a name="//apple_ref/cpp/Method/mailArchive" class="dashAnchor"></a>
            <h5><a href="#mailArchive">mailArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:mailArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Mail using the built-in Archive functionality</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>none</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L85">Source/UniversalArchive.spoon/init.lua line 85</a></td>
              </tr>
            </table>
          </section>
          <section id="outlookArchive">
            <a name="//apple_ref/cpp/Method/outlookArchive" class="dashAnchor"></a>
            <h5><a href="#outlookArchive">outlookArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:outlookArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Outlook using one of two methods:</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>none</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                  <th>Notes</th>
                  <td><ul>
<li>If the &quot;Message -&gt; Archive&quot; menu item exists, it is used (this has been added in recent versions of Outlook)</li>
<li>Otherwise, the message gets manually moved to the folder specified in <code>UniversalArchive.outlook_archive_folder</code>. The folder has to appear in the Message -&gt; Move submenu for this to work. Since this submenu only lists the last few destination folders, you have to move a message by hand the first time (or periodically if you don't archive very often).</li>
</ul>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L121">Source/UniversalArchive.spoon/init.lua line 121</a></td>
              </tr>
            </table>
          </section>
          <section id="registerApplication">
            <a name="//apple_ref/cpp/Method/registerApplication" class="dashAnchor"></a>
            <h5><a href="#registerApplication">registerApplication</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:registerApplication(appname, fn)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Register a handler function for an application.</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>appname - string containing the name of the application. If the application already has a handler, it will be replaced with the new one.</li>
<li>fn - handler function (to remove the handler for an application, use <code>nil</code>). The function receives the following arguments:<ul>
<li>self - the UniversalArchive object, so the handler can make use of all the object methods and variables.</li>
<li>where - optional &quot;destination&quot; for the archive operation. Handlers must provide a default destination when <code>where == nil</code>. Destination doesn't make sense for all applications, so the implementation of this is optional and depending on the handler.</li>
</ul>
</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L166">Source/UniversalArchive.spoon/init.lua line 166</a></td>
              </tr>
            </table>
          </section>
          <section id="sparkArchive">
            <a name="//apple_ref/cpp/Method/sparkArchive" class="dashAnchor"></a>
            <h5><a href="#sparkArchive">sparkArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:sparkArchive()</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Archive current message in Spark using the built-in Archive functionality</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>none</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L103">Source/UniversalArchive.spoon/init.lua line 103</a></td>
              </tr>
            </table>
          </section>
          <section id="universalArchive">
            <a name="//apple_ref/cpp/Method/universalArchive" class="dashAnchor"></a>
            <h5><a href="#universalArchive">universalArchive</a></h5>
            <table>
              <tr>
                <th>Signature</th>
                <td><code>UniversalArchive:universalArchive(where)</code></td>
              </tr>
              <tr>
                <th>Type</th>
                <td>Method</td>
              </tr>
              <tr>
                <th>Description</th>
                <td><p>Main entry point for archiving an item.</p>
</td>
              </tr>
              <tr>
                  <th>Parameters</th>
                  <td><ul>
<li>None</li>
</ul>
</td>
              </tr>
              <tr>
                  <th>Returns</th>
                  <td></td>
              </tr>
              <tr>
                  <th>Notes</th>
                  <td><ul>
<li>If a handler function is defined for the current application, it is called with the <code>UniversalArchive</code> object as its first argument, and the archive destination (if provided) as the second.</li>
<li>Handlers must have a &quot;default destination&quot; that gets used when no destination is provided. Not all handlers support specifying a destination. New handlers can be registered using the <code>registerApplication()</code> method.</li>
</ul>
</td>
              </tr>
              <tr>
                <th>Source</th>
                <td><a href="https://github.com/Hammerspoon/Spoons/blob/master/Source/UniversalArchive.spoon/init.lua#L143">Source/UniversalArchive.spoon/init.lua line 143</a></td>
              </tr>
            </table>
          </section>
  </body>
</html>